package com.gsm.service.impl;

import com.gsm.dao.NavDao;
import com.gsm.entity.Result;
import com.gsm.po.Nav;
import com.gsm.service.NavService;
import com.gsm.utils.IdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 导航列表(Nav)表服务实现类
 */
@Service
public class NavServiceImpl implements NavService {
    @Autowired
    private NavDao navDao;
    @Autowired
    private IdUtils idUtils;

    @Override
    public Result insertNav(Nav nav) {
        long navId = idUtils.nextId();
        nav.setNavId(navId);
        navDao.insertNav(nav);
        return Result.success();
    }

    /**
     * 根据 主键 navId 删除
     *
     * @param navId 主键
     * @return
     */
    @Override
    public Result deleteNavByNavId(Long navId) {
        navDao.deleteNavByNavId(navId);
        return Result.success();
    }

    /**
     * 修改
     *
     * @param nav 实例对象
     * @return
     */
    @Override
    public Result updateNavByNavId(Nav nav) {
        navDao.updateNavByNavId(nav);
        return Result.success();
    }

    /**
     * 根据 id 查询单条数据
     *
     * @param navId 主键
     * @return
     */
    @Override
    public Result selectNavByNavId(Long navId) {
        Nav nav = navDao.selectNavByNavId(navId);
        Result result = Result.success(nav);
        return result;
    }

    /**
     * 根据条件查询列表
     *
     * @param nav 实例对象
     * @return
     */
    @Override
    public Result selectNavList(Nav nav) {
        List<Nav> list = navDao.selectNavList(nav);
        return Result.success(list);
    }

    @Override
    public Result updateNavShowOrder(List<Long> navIds) {
        navDao.updateNavShowOrder(navIds);
        return Result.success();
    }
}